<template>
  <el-table :data="users">
    <el-table-column prop="rid" label="ID" width="140"> </el-table-column>
    <el-table-column prop="rname" label="身份信息" width="320"> </el-table-column>
    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button size="mini" @click="show(scope.row.rid)">查看</el-button>
        <el-button
          size="mini"
          type="danger"
          @click="remove(scope.row.rid)">删除</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
export default {
  name: "userList",
  data() {
    return {
      users: [],
    };
  },
  methods: {
    fetch() {
      this.$http.get("roleList").then(res => {
        if(res.data.meta.status!=200){
          this.$message({
                message:'显示失败',
                type:'error'
          })
        }
        else{
          this.users = res.data.result;
          console.log(this.users)
        }
        
      });
    },
    remove(id){
        this.$http.delete(`roleList/${id}`).then(res=>{
            console.log(res);
            this.$message({
                message:'删除成功！',
                type:'success'
            })
            this.fetch()
        })

    },
    show(rid){
      // console.log(rid)
      this.$router.push({path:`/main/showRoles?index=${rid}`});
    }
  },
  created() {
    this.fetch();
  },
};
</script>

<style>
</style>